package com.bocai.dahuatech.ui.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;

import com.bocai.dahuatech.R;
import com.bocai.dahuatech.base.BaseActivity;
import com.bocai.dahuatech.utils.MyConst;
import com.bocai.dahuatech.utils.SharePrefencesUtil;


public class SplashActivity extends BaseActivity {

	@Override
	protected int contentView() {
		return R.layout.activity_splash;
	}

	@Override
	protected void initView() {
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				jumpToLogin();
			}
		},2000);
	}


	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		MyConst.setIslunched(false);
	}

	public void jumpToLogin() {
		SharedPreferences preferences1 = getSharedPreferences("user", MODE_APPEND);
		int count = preferences1.getInt("count", 0);

			if(!SharePrefencesUtil.getIsRememberPsd(this)){
				SharedPreferences preferences=getSharedPreferences("user",MODE_PRIVATE);
				SharedPreferences.Editor editor=preferences.edit();
				editor.putInt("FAccessFlag",0);
				editor.commit();
				startActivity(new Intent(this, HomeActivity.class));
				finish();
			}else{
				MyConst.user_id=SharePrefencesUtil.getUser_id(this);
				Intent i = new Intent(SplashActivity.this, HomeActivity.class);
				startActivity(i);
				MyConst.setIslunched(false);
				finish();

			}

//		}
		Editor editor = preferences1.edit();
		//存入数据
		editor.putInt("count", ++count);
		//提交修改
		editor.commit();
		}

}
